package com.luban.bio;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @ClassName SocketClient
 * @Description 498982703@qq.com
 * @Author gary
 * @Date 2021/2/19 8:55
 * @Version 1.0
 */
public class SocketClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost", 9000);
        //send data to server
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("helloServer".getBytes());
        outputStream.flush();
        //recieve data from server
        byte[] bytes = new byte[1024];
        socket.getInputStream().read(bytes);
        System.out.println("accept server data:" + new String(bytes));
        socket.close();

    }
}
